<!doctype html>
<!--
# Project Kimchi
#
# Copyright IBM Corp, 2016
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
-->
<html>
    <head>
        <title>Kimchi Serial Console</title>
        <!--[if IE  lte 9]><link rel="shortcut icon" href="/images/favicon.ico"><![endif]-->
        <link rel="shortcut icon" href="/images/favicon.ico">
        <style>
            html {
                background-color: #3A393B;
            }

            body {
                width: 50%;
                height: 60%;
                margin-left: auto;
                margin-right: auto;
            }

            .terminal {
                width: 100%;
                height: 100%;
                border: #000 solid 3px;
                font-family: "DejaVu Sans Mono", "Liberation Mono", monospace;
                font-size: 16px;
                color: #f0f0f0;
                background: #000;
            }

            .terminal-cursor {
                color: #000;
                background: #f0f0f0;
            }
        </style>
        <script src="../libs/term.js"></script>
        <script>
        ;(function() {
            window.onload = function() {
                var params = new Map()
                var query_string = window.location.href.split('?');
                for (var i = 1; i < query_string.length; i++) {
                    query_string[i].split('&').forEach(function(val) {
                        param = val.split('=');
                        params.set(param[0], param[1]);
                });
            }

            var url = 'wss://' + window.location.hostname + ':' + params.get('port');
            url += '/' + params.get('path');
            url += '?token=' + params.get('token');
            var socket = new WebSocket(url, ['base64']);
            var term = new Terminal({
                cols: 80,
                rows: 35,
                useStyle: true,
                screenKeys: true,
                cursorBlink: true
            });

            term.on('data', function(data) {
                socket.send(window.btoa(data));
            });

            socket.onmessage = function(event) {
                var message = event.data;
                term.write(window.atob(message));
            };

            term.open(document.body);
          };
        }).call(this);
        //# sourceURL=serial.js
        </script>
    </head>
    <body>
    </body>
</html>
